<template>
  <div class="nav">
    <div class="nav-title">租币当钱花</div>
    <div class="nav-list">
      <div class="nav-item" v-for="item in navList" :key="item.title" @click="item.cb">
        <div class="nav-item-top">
          <div class="nav-item-title">
            {{ item.title }}
          </div>
          <div class="nav-item-description">
            {{ item.description }}
          </div>
        </div>
        <div class="nav-item-icon">
          <img :src="item.icon" alt="" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import router from '@/router'
import icon1 from '../../../assets/image/1.png'
import icon2 from '../../../assets/image/2.png'
import icon3 from '../../../assets/image/3.png'

interface NavItem {
  title: string
  description: string
  icon: string
  cb: () => void
}

const emit = defineEmits(['showTaskPanel'])

const navList: NavItem[] = [
  {
    title: '租币商城',
    description: '租币当钱花',
    icon: icon1,
    cb: () => {
      router.push('/shop')
    }
  },
  {
    title: '租币任务',
    description: '租币赚不停',
    icon: icon2,
    cb: () => {
      emit('showTaskPanel')
    }
  },
  {
    title: '租币赢现金',
    description: '每天分万元奖金',
    icon: icon3,
    cb: () => {}
  },
  {
    title: '租币抽奖',
    description: '天天免租金',
    icon: icon1,
    cb: () => {}
  },
  {
    title: '租币商城',
    description: '租币当钱花',
    icon: icon1,
    cb: () => {
      router.push('/shop')
    }
  },
  {
    title: '租币任务',
    description: '租币赚不停',
    icon: icon2,
    cb: () => {
      emit('showTaskPanel')
    }
  },
  {
    title: '租币赢现金',
    description: '每天分万元奖金',
    icon: icon3,
    cb: () => {}
  },
  {
    title: '租币抽奖',
    description: '天天免租金',
    icon: icon1,
    cb: () => {}
  }
]
</script>

<style scoped lang="less">
.nav {
  width: 100vw;
  padding: 0 10px 15px 10px;
  box-sizing: border-box;

  .nav-title {
    margin-bottom: 10px;
  }
  .nav-list {
    width: 100%;
    height: 110px;
    white-space: nowrap;
    overflow-x: auto;
    &::-webkit-scrollbar {
      display: none;
    }

    .nav-item {
      width: 25%;
      display: inline-block;
      margin-right: 10px;
      background-color: #f6f8fa;
      .nav-item-top {
        padding: 10px;
        .nav-item-title {
          font-size: 12px;
        }
        .nav-item-description {
          font-size: 10px;
          color: #969696;
        }
      }
      .nav-item-icon {
        text-align: right;
        img {
          width: 50px;
        }
      }
    }
  }
}
</style>
